var express        = require('express'),
    router         = express.Router(),
 	mongoosekeeper =  require('../lib/mongoosekeeper'),
 	articleModel   =  require('../models/articleModel');

/* GET home page. */
router.get('/', function(req, res) {

	mongoosekeeper.use(queryArticle,function(err,list){
		if(err){
			throw err;
		}
		else{
			res.render('index',{data:list});
		}
			
	});	
    
});

function queryArticle(proxy){
	var search = {} ; //获取所有文章
    var query = articleModel.find(search).limit(25); 
    query.sort('-create_date');
    query.exec(proxy);
}

module.exports = router;
